﻿using Abp.Domain.Repositories;
using JYJ.AiYard.StationManagement.TbYardIssuedCards;
using JYJ.AiYard.StationManagement.TbYardParamsSets;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using JYJ.AiYard.StationManagement.TbStationParams;
using JYJ.AiYard.StationManagement.TbDiscountBills;
using JYJ.AiYard.StationManagement.TbSales;
using JYJ.AiYard.StationManagement.TbObjects;
using JYJ.AiYard.StationManagement.TbClientRegisters;
using JYJ.AiYard.StationManagement.TbYardUserParkings;
using JYJ.AiYard.StationManagement.TbYardBlackLists;
using JYJ.AiYard.StationManagement.TbYardLovingLists;
using JYJ.AiYard.StationManagement.TbYardMonthCardOnlines;
using JYJ.AiYard.StationManagement.YardReport;
using JYJ.AiYard.StationManagement.TbStations; 
using System.Data;
using JYJ.AiYard.StationManagement.TbYardPayMonthCards;
using JYJ.AiYard.StationManagement.TvDigitalPay;

namespace JYJ.AiYard.Database
{
    public interface IAiYardDbTableIssuedCard : IRepository<TbYardIssuedCardDb, long>
    {

        Task<List<TbYardIssuedCardDb>> QueryTableIssuedCard(List<long> Station_ID, string FilterText, bool onlyShowBAccount, bool NoBAccount);

        Task<TbYardIssuedCardDb> QueryTableIssuedCardById(long Id);

        //注销
        Task CardLogoutIssuedCard(TbYardIssuedCardDb tc);

        //发卡、延期
        Task<Dictionary<string, string>> CreateIssuedCard(TbYardIssuedCardDb tc,int MonthCount, bool BAccount);

        //导入月卡数据
        Task<Dictionary<string, string>> BatchLoadCardNo(string fileName, long Station_ID, int TenantId, int OP_User_Id);

        //获取月卡延期规则
        Task<List<TbYardMonthCardOnline>> GetTbYardMonthCardOnlines(long Station_ID);

        //按包月规则计算
        Task<TbYardIssuedMonthOnlineResult> CaleMonthCardOnlines(long IssuedId, long Station_Id, int CardTypeId,int MonthCount);

        //保存支持结果
        Task<bool> AddIssuedCardPay(long Station_Id, long IssuedId, long IssuedOpId,
            DateTime EndTime, string OpType, decimal PurMoney, decimal PayMoney, decimal YHMoney, string PayType);

        //删除下载标识
        Task<bool> DeleteDownTag(long Station_Id, string IdList);
         
        Task TestTable();

        //获取设备号
        string GetCard_IOPower(long Issued_ID);

        //获取车位
        string GetParkingPos(long User_ID, long StationId);

        //获取图片文件ID
        List<string> GetImagesFileId(int IN_OUT, long RecordId, long StationId);
        bool GetImagesFileId2(int IN_OUT, long RecordId, long StationId, ref string StationNo, ref string InImages, ref string OutImages);

        //获取电话  编号、姓名、部门
        Dictionary<string, string> GetPhone(long User_ID);

        List<TbrYardUserDto> GetUserList(long Station_ID, string QueryUserName);

        Dictionary<string, string> gettestUser(long Station_ID);

        Task<List<TbYardParamsSetDb>> QueryTableYardParamsSet(List<long> Station_ID);

        //车场参数List
        List<TbStationParam> GetTbStationParamTable(long Station_ID);

        //获取临时密码
        string GetTbStationParamTablePassword();

        //开启B账功能
        bool OpenBAccount(string StationNo);

        //保存车场参数
        Dictionary<string, string> UpdateStationParams(List<TbStationParam> input);

        //初始化参数
        void InitYardParams(long Station_Id, long Client_Id);

        //初始化参数
        void InitYardParams(long Station_Id, long Client_Id, string synm, string syip, string syds, string syty, string syvl, bool sygj);
         
        //添加优惠券数据
        Dictionary<string, string> AddDiscountBills(TbDiscountBill input);

        //查询优惠券数据
        List<TbDiscountBillDb> GetTbDiscountBillTable(long Station_ID);

        //查询基础资料数据
        List<TbObjects> GetTbObjects(List<long> Station_ID, string FilterText);

        //获取停车场场所信息
        List<TbStation> GetTbStations(long Station_ID);

        //获取当前ICP信息
        string GetICPfiling();

        //根据用户编号获取组织编号
        long GetCurrenUserOrganizationUnit(long userId);

        //根据用户编号获取组织编号及子项
        List<long> GetCurrenUserOrganizationAndChildrenUnit(long userId);
        List<TbStationTreeDto> GetCurrenUserOrganizationAndChildrenUnitResultDto(long userId);

        //查询客户端数据
        List<TbClientRegister> GetTbClientRegister(List<long> Station_ID, string FilterText);

        //查询岗亭操作用户
        List<TbrGTOpUser> GetTbGTUser(List<long> Station_ID);
        //查询收费类型
        List<string> GetTbCardType(List<long> Station_ID);

        //查询出场通道
        List<TbrOutMach> GetOutMach(List<long> Station_ID);

        //查询部门信息
        List<TbrYardDepart> GetDepartList(List<long> Station_ID);

        //车位管理查询
        List<TbYardUserParkingVML> GetTbYardUserParkinr(List<long> Station_ID, string FilterText);

        //黑名单查询
        List<TbYardBlackListVML> GetTbYardBlackList(List<long> Station_ID, string FilterText);

        //亲情名单查询
        List<TbYardLovingListVML> GetTbYardLovingList(List<long> Station_ID, string FilterText);

        //月卡分时
        List<TbYardPayMonthCardVML> GetTbYardPayMonthCard(List<long> Station_ID, long Id, string FilterText);

        //月卡分时 时间段
        bool UpdatePayMonthCard(int CardTypeId, string CardTypeName, long StationId, DateTime BTime, DateTime ETime);

        /// 批量授权        
        //Dictionary<string, string> BatchAuthorizationIssuedCard(TbYardIssuedCardDb tc);
        int BatchAuthorizationIssuedCard(long Issued_ID, int TenantId, long Station_Id, string Card_IOPower);

        //查询优惠券主表数据
        List<TbDiscountBillMaster> GetTbDiscountBillMaster(List<long> Station_ID, string FilterText, int SaleID);

        TbDiscountBillMaster GetTbDiscountBillMasterById(long Id);
        bool DeleteDiscountBill(long Id, long? UserId, bool isAll);
        bool DeleteDiscountBill(List<long> Id, long? UserId);

        // 判断是否是商户且是否是组织        
        int IsUserOrganizationUnit(long UserID);

        //判断是否存在B账权限
        bool isBAccountQuery(long userId);

        //更新审核密码
        string getAudUser(int type, long stationId);
        bool isAudUser(long userId);
        int getAudUserType(long userId);
        string getAudPassword(long userId);
        int getAudPasswordType(long userId);
        bool isUpdateAudPassword(long userId,string password);

        //判断当前发行记录是否为隐藏记录
        bool isHideIssuedRecord(long IssuedId, long StationId);

        //保存当前发行记录为隐藏记录
        bool saveHideIssuedRecord(long IssuedId, long StationId, int ACC);

        //返回组织NO
        string GetTbObject_NO(long Station_ID);

        //检查删除权限
        bool CheckIsForeignKey(long Id, long Station_Id, string TableName);

        //检查是否具备权限
        bool CheckIsAbpAuthorize(long UserId, string Authorize);

        // 获取当前租户下所有场所
        List<TbStation> GetAllStationByTenantID(int TenantID);
        // 获取当前场所下的所有商户
        List<TbSale> GetAllSalesByStationID(long StationId);
        //获取当前场所下所有免单券类型
        List<string> GetAllBillNameByStationID(long StationId);

        //数字人民币批量扣款--订单列表
        List<tVDIGITALPAYMAIN> GetDIGITALPAY(List<long> StationId, DateTime? bTime, DateTime? eTime,bool? isDelete);

        //获取数字人民币批量扣款
        List<tVDIGITALPAYIds> GetDIGITALPAY(long StationId,string billNo);

        //导入月卡数据
        Task<Dictionary<string, string>> BatchLoadDigitalPay(int isDigityPay, string name, bool isCheckerr, bool isEdit, string fileName, string billno, string title, long stationId, int TenantId, int opUserId, string opUserName, string opUserTureName);

        //审核数字人民币扣款单据
        Task<Dictionary<string, string>> CheckDigitalPayByBillNo(long stationId, string billNo, string checkStatus, string checkMemo, long checkuser, string checkuserName, string checkuserTrueName);

        int insertOutYardrecord(string plateNo, int plateColor, string owner, DateTime InTime, DateTime OutTime, string inGate, string outGate, long userId, string userTureName, string StationNo);

        bool insertOutYardpay(string billNo, string plateNo, int recordId, decimal recvAmt, long userId, string userTureName, long clientId, string StationNo);

        bool updateDigityResult(string billNo, string plateNo, int recordId, decimal tradeAmt, string tradeStatus, string errorCode, string errorMessage, DateTime requestTime, DateTime reponseTime, DateTime tradeTime, int isDigityPay);

        //获取单号
        string GetBillNo(long stationId);

        bool getClientInfor(string billNo, long stationId, int isDigity, ref string md5Key, ref string stationNo, ref string stationName, ref long clientId, ref string clientNo, ref string clientName);

        //获取明细
        Task<List<TvDigitalPayDto>> GetBillInfo(long stationId, string billNo, bool ischeck);

        //转换无感支付
        Task<bool> ChangeBillWG(long stationId, string billNo, long opuserId, string opuserName, string opuserTureName);

        // 车辆进出数据查询
        YardPagedResult<TbrInYard> GetTbrInYard(TbrInYardInput pc, bool NoBAccount);
        //车辆进出数据查询导出
        List<TbrInYard> ExportTbrInYard(TbrInYardInput pc, bool NoBAccount);
        //场内记录导出
        List<TbrInYardSql> ExportInYardSql(TbrInYardInput pc, bool NoBAccount);
        //车辆出场数据查询
        YardPagedResult<TbrOutYard> GetTbrOutYard(TbrOutYardInput pc, bool NoBAccount);
        //车辆出场数据查询
        YardPagedResult2<DataTable> GetTbrOutYard2(TbrOutYardInput2 pc, bool NoBAccount);
        //车辆出场数据导出
        List<TbrOutYard> ExportTbrOutYard(TbrOutYardInput pc, bool NoBAccount);
        //车辆出场数据导出
        DataTable ExportTbrOutYard2(TbrOutYardInput2 pc, bool NoBAccount);
        //车辆开闸数据查询
        YardPagedResult<TbrOpenGate> GetTbrOpenGate(TbrOpenGateInput pc);
        //车辆开闸数据导出
        List<TbrOpenGate> ExportTbrOpenGate(TbrOpenGateInput pc);
        //车辆操作报表查询
        YardPagedResult<TbrIssuedOpCard> GetTbrIssuedOpCard(TbrIssuedOpCardInput pc, bool NoBAccount);
        //车辆操作报表导出
        List<TbrIssuedOpCard> ExportTbrIssuedOpCard(TbrIssuedOpCardInput pc, bool NoBAccount);
        //车辆发行报表查询
        YardPagedResult<TbrIssued> GetTbrIssued(TbrIssuedInput pc, bool NoBAccount);
        //车辆发行报表导出
        List<TbrIssued> ExportTbrIssued(TbrIssuedInput pc, bool NoBAccount);
        //停车券明细查询
        YardPagedResult2<DataTable> GetTbrDiscount(TbrDiscountInput pc, bool NoBAccount);
        //停车券明细导出
        List<TbrDiscount> ExportTbrDiscount(TbrDiscountInput pc, bool NoBAccount);
        //交班统计报表
        YardPagedResult<TbrChangeClass> GetTbrChangeClass(TbrChangeClassInput pc, bool NoBAccount);
        //交班统计报表
        List<TbrChangeClass> ExportTbrChangeClass(TbrChangeClassInput pc, bool NoBAccount);
        //交班统计报表
        YardPagedResult2<DataTable> GetTbrChangeClass2(TbrChangeClassInput pc, bool NoBAccount);
        //交班统计报表
        DataTable ExportTbrChangeClass2(TbrChangeClassInput pc, bool NoBAccount);
        //收费统计报表
        YardPagedResult<TbrStatics> GetTbrStatics(TbrStaticsInput pc, bool NoBAccount);
        //收费统计报表
        List<TbrStatics> ExportTbrStatics(TbrStaticsInput pc, bool NoBAccount);
        //收费统计报表2
        YardPagedResult2<DataTable> GetTbrStatics2(TbrStaticsInput pc, bool NoBAccount);
        //收费统计报表2
        DataTable ExportTbrStatics2(TbrStaticsInput pc, bool NoBAccount);
        //收费统计报表3
        YardPagedResult2<DataTable> GetTbrStatics3(TbrStaticsInput pc, bool NoBAccount);
        //收费统计报表3
        DataTable ExportTbrStatics3(TbrStaticsInput pc, bool NoBAccount);
        //在线支付查询
        YardPagedResult<TbrOnlinePay> GetTbrOnlinePay(TbrOnlinePayInput pc, bool NoBAccount);
        //在线支付查询
        List<TbrOnlinePay> ExportTbrOnlinePay(TbrOnlinePayInput pc, bool NoBAccount);
        //开票结果查询
        YardPagedResult<TbrInvoice> GetTbrInvoice(TbrInvoiceInput pc, bool NoBAccount);
        //删除开票记录
        bool DeleteInvoice(List<int> delkyes);
        //开票结果导出
        List<TbrInvoice> ExportTbrInvoice(TbrInvoiceInput pc, bool NoBAccount);
        //删除开票记录
        bool DeleteInvoiceRecord(List<int> delkeys);
        //路政对账单
        YardPagedResult<rRoadPayResults> GetrRoadPayResults(rRoadPayResultsInput pc, bool NoBAccount);
        //路政对账单
        List<rRoadPayResults> ExportrRoadPayResults(rRoadPayResultsInput pc, bool NoBAccount);
        //路政缴费凭证
        YardPagedResult<rRoadbillInfos> GetrRoadbillInfos(rRoadbillInfosInput pc, bool NoBAccount);
        //路政缴费凭证
        List<rRoadbillInfos> ExportrRoadbillInfos(rRoadbillInfosInput pc, bool NoBAccount);
        //路政错峰停车
        YardPagedResult<rRoadStagger> GetrRoadStagger(rRoadStaggerInput pc, bool NoBAccount);
        //路政错峰停车
        List<rRoadStagger> ExportrRoadStagger(rRoadStaggerInput pc, bool NoBAccount);
        //车流数据查询
        YardPagedResult2<DataTable> GetTbrStatisticsCL(TbrStaticsCLInput pc);
        //车流数据导出
        DataTable ExportTbrStatisticsCL(TbrStaticsCLInput pc);
        
    }
}
